package cn.qiba.sms.core.enums;

import cn.hutool.core.util.StrUtil;
import cn.qiba.sms.bo.aliyun.AliyunSmsBO;
import cn.qiba.sms.bo.tencent.TencentSmsBO;
import cn.qiba.sms.service.impl.AliyunSmsServiceImpl;
import cn.qiba.sms.service.impl.TencentSmsServiceImpl;

public enum ChannelEnums {
    ALIYUN("aliyun","阿里云", AliyunSmsServiceImpl.class, AliyunSmsBO.class),
    TENCENT("tencent","腾讯云", TencentSmsServiceImpl.class, TencentSmsBO.class),
    ;

    private String code;
    private String name;
    private Class service;
    private Class bo;

    ChannelEnums(String code, String name, Class service, Class bo) {
        this.code = code;
        this.name = name;
        this.service = service;
        this.bo = bo;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Class getService() {
        return service;
    }

    public void setService(Class service) {
        this.service = service;
    }

    public Class getBo() {
        return bo;
    }

    public void setBo(Class bo) {
        this.bo = bo;
    }

    /**
     * 根据code获取通道
     * @param code
     * @return
     */
    public static ChannelEnums getByCode(String code){
        if(StrUtil.isNotEmpty(code)){
            for(ChannelEnums e:ChannelEnums.values()){
                if(e.getCode().equals(code)){
                    return e;
                }
            }
        }
        return null;
    }
}
